package com.rabbit.config;

import com.rabbit.service.ConfigService;
import com.rabbit.service.DictService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Created by zjw on 2022/2/23 9:38 下午
 */
@Component
@Slf4j
public class CacheInitialize implements ApplicationRunner {

    @Resource
    private ConfigService configService;

    @Resource
    private DictService dictService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        // 1. 加载参数缓存
        configService.refreshCache();
        // 2. 加载字典缓存
        dictService.queryDictData();
        log.info("***** 初始化Config缓存完毕 *****");
    }
}
